package com.hqyj.javaSpringBoot.modules.common.dao;

import com.hqyj.javaSpringBoot.modules.common.entiy.ExceptionLog;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface ExceptionLogDao {

    /**
     * 添加系统的报错信息
     * @param exceptionLog
     */
    @Insert("insert into common_exception_log " +
            " (create_date,ip,path,class_name,method_name,exception_type,exception_message)" +
            " value(#{createDate},#{ip},#{path},#{className},#{methodName}," +
            " #{exceptionType},#{exceptionMessage})")
    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    void insertExceptionLog(ExceptionLog exceptionLog);

    /**
     * 添加之前查询该报错信息日志是否已经存在
     * @param exceptionLog
     * @return
     */
    @Select("select * from common_exception_log where class_name=#{className} and method_name=#{methodName}" +
            " and exception_type=#{exceptionType} and exception_message=#{exceptionMessage}")
    List<ExceptionLog> getExceptionLog(ExceptionLog exceptionLog);

}
